package com.atguigu.userprofile.dao

import com.atguigu.userprofile.bean.TagInfo
import com.atguigu.userprofile.util.MySqlUtil

object TagInfoDAO {


   def  getTagInfoByTaskID(taskId:String): TagInfo ={
     var tagInfo:TagInfo=null;
     val sql = s"select  * from  tag_info where  tag_task_id=$taskId"
     val tagInfoOpt: Option[TagInfo] = MySqlUtil.queryOne(sql,classOf[TagInfo],true)
     if(tagInfoOpt==None){
       throw  new RuntimeException(s"no tag for task_id:$taskId" )
     }else{
       tagInfo=tagInfoOpt.get
     }
     tagInfo
   }

  def getTagInfoListWithOn(): List[TagInfo] ={
    val sql =
      s"""
         |  select tg.* from
         |  tag_info  tg  , task_info tk
         |   where tg.tag_task_id=tk.id
         |  and   tk.task_status='1'
       """.stripMargin
    val tagInfoList: List[TagInfo] = MySqlUtil.queryList(sql,classOf[TagInfo] ,true)
    tagInfoList
  }
}
